package com.shqcjd.generalplatformprojectclient.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.shqcjd.generalplatformprojectclient.R;
import com.shqcjd.generalplatformprojectclient.model.pojo.GuidanceHistoryBean;
import com.shqcjd.generalplatformprojectclient.ui.adapter.GuidanceFileAdapter;
import com.shqcjd.generalplatformprojectclient.ui.base.BaseActivity;
import com.shqcjd.generalplatformprojectclient.ui.base.BasePresenter;
import com.shqcjd.generalplatformprojectclient.util.UIUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class GuidanceDetailsActivity extends BaseActivity {
    @BindView(R.id.btn_back)
    Button btnBack;
    @BindView(R.id.tv_toolbar_center)
    TextView tvToolbarCenter;
    @BindView(R.id.ib_toolbar_right)
    ImageButton ibToolbarRight;
    @BindView(R.id.rv_guidance_file)
    RecyclerView rvGuidanceFile;
    @BindView(R.id.tv_memo)
    TextView tvMemo;
    private GuidanceFileAdapter guidanceFileAdapter;
    private Context context;
    private List<GuidanceHistoryBean.GuideVideoBean> list;
    private String comment;

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_guidance_details;
    }

    @Override
    public void initView() {
        tvToolbarCenter.setText("远程指导文件");
        tvMemo.setText(comment);
        guidanceFileAdapter = new GuidanceFileAdapter(null, this);
        rvGuidanceFile.setLayoutManager(new LinearLayoutManager(this));
        DefaultItemAnimator animator = new DefaultItemAnimator();
        rvGuidanceFile.setItemAnimator(animator);
        rvGuidanceFile.setAdapter(guidanceFileAdapter);
        guidanceFileAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                List<GuidanceHistoryBean.GuideVideoBean> list = adapter.getData();
                Intent it = new Intent(context, UIUtils.previewClass(list.get(position).extension));
                it.putExtra("url", list.get(position).url);
                it.putExtra("name", list.get(position).filename);
                startActivity(it);
            }
        });
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        guidanceFileAdapter.setNewData(list);
    }

    @Override
    public void init() {
        super.init();
        list = (List<GuidanceHistoryBean.GuideVideoBean>) getIntent().getSerializableExtra("gList");
        comment = getIntent().getStringExtra("comment");
        context = this;
    }


    @OnClick(R.id.btn_back)
    public void onViewClicked() {
        finish();
    }
}
